(function($f) { $f.extend.page("85f23768-0f04-435b-bcd5-fad6ee17aff5", function(self) {

	"use strict";

	// NOTE: This is same as any other plugin with two exceptions:
	// 1. Extended using page(...) instead of custom(...) method
	// 2. There is no name given, only Id
	// 	  there would geberally be multiple pages in one app, but at any given point in time
	//    only one page will be current and that current page can be accessed with $f.page, 
	//    therefore a seperate name is not required for each page
	
	// plugin info
	this.info = {
		title: "My Page 1"
	};

	// plugin variables
	// value of these variables is NOT maintained across page refresh
	this.vars = { 
		allLifecycleEvents: []
	};
	
	// plugin entries in session (contents here-in must be JSON serializable)
	// if items are defined here, these will be maintained in session
	// items must be defined here with their initial value - it will be replaced with an object
	// at runtime which can be accessed as:
	// this.session.<name>.get() to get it, this.session.<name>.set(<value>) to set it
	this.session = { 
		var1: 0,		
		var2: 0,
		var3: "",
		var4: false
	};
	
	// pre-initialization handler
	// called just after plugin instance is created and no features or includes are processed
	// returns (boolean): 
	//	true: if success 
	//	false: if failed
	this.onPreInit = function() { 
		self.vars.allLifecycleEvents.push("<p><b>preInit:</b> " + self.info.title + " plugin is instantiated and will be initialized.");
		return true;
	};
	
	// initialization handler
	// called when all includes are processed and features etc. are added
	// returns (boolean): 
	//	true: if success 
	//	false: if failed
	this.onInit = function() { 
		self.vars.allLifecycleEvents.push("<p><b>init:</b> " + self.info.title + " plugin is initialized now.");
		return true;
	};

	// load handler
	// returns: (void)
	this.onLoad = function() {
		self.vars.allLifecycleEvents.push("<p><b>load:</b> " + self.info.title + " plugin is loaded now.");
	};
	
	// on before page load handler
	// this is called before page has started loading but yet nothing is done
	// Notes: 1. page load cannot be stopped
	// returns (void):
	this.onBeforeLoad = function() {
		self.vars.allLifecycleEvents.push("<hr/><p><b>onBeforeLoad:</b> " + self.info.title + " content has started loading.");
	};
	
	// on after page load handler
	// this is called after page has completed loading and is ready to use
	// returns (void):
	this.onAfterLoad = function() {
		self.vars.allLifecycleEvents.push("<p><b>onAfterLoad:</b> " + self.info.title + " content loading completed.<hr/>");
	};
	
	// ready handler
	// returns: (void)
	this.onReady = function() {
		self.vars.allLifecycleEvents.push("<p><b>ready:</b> " + self.info.title + " plugin is ready now.");
		
		// show
		var div = $("#lifecycle");
		$.each(self.vars.allLifecycleEvents, function(i, item) {
			div.append(item);
		});
		
		// title
		$("#title").append("<h3>" + self.info.title + "</h3>");
		
		// assign session values in a new session only
		if ($f.sess.isNew.get()) {
			self.session.var1.set(10);
			self.session.var2.set(Date.now());
			self.session.var3.set(self.info.title + " string");
			self.session.var4.set(true);
		};
		
		// session items
		div = $("#sessionItems");
		div.append('<p><span class="label label-success">var1</span> = ' + self.session.var1.get().toString() + "</p>");
		div.append('<p><span class="label label-success">var2</span> = ' + self.session.var2.get().toString() + "</p>");
		div.append('<p><span class="label label-success">var3</span> = ' + self.session.var3.get().toString() + "</p>");
		div.append('<p><span class="label label-success">var4</span> = ' + self.session.var4.get().toString() + "</p>");
	};
	
	// unload handler
	// returns: (void)
	this.onUnload = function() { 
		// Application is unloading, plugin can do any unload time processing now.
		// alerts don't work from within this method
	};
	
	// NOTE: No layout is defined, in this case it will auto-wire
	// using page JS file name. 
	// That means myPage1.*.js will automatically be wired with myPage1.html at same path

	// on before page unload handler
	// this is called before page has started unloading but yet nothing is done
	// Notes: 1. unload cannot be stopped
	//        2. alerts might not work from this function in some browsers
	// returns (void):
	this.onBeforeUnload = function() {
		// Page content is unloading, plugin can do any unload time processing now.
		// alerts don't work from within this method
	};
}); }(fluid));
